package com.alvin.commonlibrary

import android.os.Bundle
import android.view.SurfaceHolder
import android.widget.Toast

import com.common.zxing.BaseCaptureOaActivity
import com.google.zxing.Result

/**
 * Created by ch999android on 2018/7/9.
 */

class ZxingScanactivityOa : BaseCaptureOaActivity() {

    /**
     * 获取状态栏高度——方法1
     */
    //获取status_bar_height资源的ID
    //根据资源ID获取响应的尺寸值
    val statusHeight: Int
        get() {
            var statusBarHeight1 = -1
            val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
            if (resourceId > 0) {
                statusBarHeight1 = resources.getDimensionPixelSize(resourceId)
            }
            return statusBarHeight1

        }


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //        autoEnlarged = true;
        playSound = true


    }

    override fun surfaceCreated(holder: SurfaceHolder) {
        super.surfaceCreated(holder)
        setStatusViewHeight(statusHeight)

    }

    override fun handleDecodeInternally(rawResult: Result) {
        Toast.makeText(this, rawResult.text, Toast.LENGTH_SHORT).show()
        restartPreviewAfterDelay(0L)
        //        startActivity(new Intent(this, MainActivity.class));
    }
}
